<?php
	class SearchAction extends BaseAction{
	function index(){
	
		import('ORG.Util.Page');							// 导入分页类
		$key=isset($_GET['keywords'])?$_GET['keywords']:NULL;
		if($key != null){
		
		$zhaopin=M("zhaopin");
		
		$condition['title']=array('like',array('%'.$key.'%'));


		if($this->cityid!=370){
			$condition['cityid']=$this->cityid;
			
		}
		

	    $count  = $zhaopin->where($condition)->count();	// 查询满足要求的总记录数
		
		$Page   = new Page($count,10);
		
		$Page->parameter = $row; //此处的row是数组，为了传递查询条件
		
		$Page->lastSuffix = false;
		
		$temp = $zhaopin->where($condition)->limit($Page->firstRow.','.$Page->listRows)->select();
	    
		foreach ($temp as $v){
			 $v['cate'] =M('Category')->where("id=".$v['cid'])->getField("path");
			 $v['city'] = M('city')->where('id='.$v['cityid'])->getField("pinyin");
	       $searchlist[]=$v;
	   }
		
		
		$show  = $Page->show();								// 分页显示输出
		

		$this->assign('key',$key);
		
		$this->assign('searchlist',$searchlist);
		
		$this->assign("number",$count);
		
		$this->assign('page',$show);						// 赋值分页输出
		}
		
		$this->display();		
		}
	}
?>